<?php
/**
 * Created By PhpStorm.
 * User: RenJianHong
 * Date: 2021-08-03 14:32
 */

namespace Modules\Order\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Schema;

class OrderRefund extends BaseModel
{
    protected $table = "order_refund";
    protected $guarded = [];   

    /**
     * 设置退款方式数组值
     * @return string[]
     */
    public static function getRefundPayType()
    {
        return [
            1 => "原路返回",
            2 => "退回余额",
            3 => "线下转款"
        ];
    }

    /**
     * 售后订单状态
     */
    public function getRefundStatus($refund)
    {
        if($refund['refund_status'] == 0){
            if($refund['is_agree'] == 1){
                if($refund['is_user_send'] == 1){
                    return '用户已发货';
                }else{
                    return '待用户发货';
                }
            }else{
                return '待处理';
            }
        }elseif($refund['refund_status'] == 1){
            if($refund['refund_type'] == 1){
//                return '已退款';
                return '已退货退款';
            }elseif($refund['refund_type'] == 2){
//                return '已退货';
                return '已同意换货';
            }
            
        }elseif($refund['refund_status'] == 2){
//            if($refund['refund_type'] == 3){
//                return '已同意换货';
//            }
            if($refund['refund_type'] == 2){
                return '已同意换货';
            }
        }elseif($refund['refund_status'] == 3){
            if($refund['refund_type'] == 1){
//                return '已拒绝退款';
                return '已拒绝退货退款';
            }if($refund['refund_type'] == 2){
//                return '已拒绝退货';
                return '已拒绝换货';
            }else{
                return '已拒绝换货';
            }
            
        }
    }

    /**
     * 申请售后类型
     */
    public function getRefundType($type)
    {
        if($type == 1){
//            return '仅退款';
            return '退款退货';
        }elseif($type == 2){
//            return '退款退货';
            return '换货';
        }elseif($type == 3){
            return '换货';
        }else{
            return '其他';
        }
    }

    public function refundPayType($type)
    {
        if($type == 1){
            return '原路返回';
        }elseif($type == 2){
            return '退回余额';
        }elseif($type == 3){
            return '线下转账';
        }
    }
}